home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / emacs16d.zip / _BUFFERS.MIN next >
Text File  |  1992-02-15  |  8KB  |  375 lines

  1.  
  2.  
  3. Name:Ffilename
  4. This is the filename that we store the fundamental library in.
  5. [*]emacs[*]
  6.  
  7.  
  8. Name:F:eval-current-buffer
  9. [*]#(sp,[)
  10. #(ds,temp,#(rm,]))
  11. #(==,##(gs,temp),,,(#(an,"##(gs,temp)")))[*]
  12.  
  13.  
  14. Name:F:kill-buffer
  15. Delete a buffer.
  16. [*]#(ds,value,##(buffer-number.##(ba,-1)))
  17. #(Fcompleting-readline,Buffer: ,(
  18.     #(Ffind-buffer,##(value),,(
  19.         #(Fok-to-trash-buffer,(
  20.             #(Fkill-buffer)
  21.         ))
  22.     ),(
  23.         #(Ferror,No buffer named ##(value))
  24.     ))
  25. ),(
  26.     #(Fmultiple,(Fdelete-n-chars,12),##(ls,(,),buffer-name.##(value)##(2nd-half)),SELF)
  27. ),-)
  28. [*]
  29.  
  30.  
  31. Name:F:list-buffers
  32. Display a list of the buffers.
  33.  
  34. [*]#(an,Working ...)
  35. #(ow,(
  36.  MR Buffer          Lines   Mode           File
  37.  -- ------          ------  ----           ----
  38. )
  39. #(Fexcurse-buffer,(#(Ffor-all-buffers,Flist-buffers-do)))
  40. (
  41. ))
  42. #(an)
  43. #(Fhit-any-key)
  44. [*]
  45.  
  46.  
  47. Name:F:next-buffer
  48. Step forward in buffer list.
  49. [*]#(n?,current-buffer,,(
  50.     #(ds,current-buffer,##(ba,-1))
  51. ))
  52. #(==,##(ba,#(++,#(ba,-1),1)),0,(
  53.     #(ba,##(current-buffer))
  54.     #(Fenter-local-modes)
  55.     #(es,current-buffer)
  56.     #(Fmessage,Last buffer)
  57. ),(
  58.     #(n?,buffer-number.##(ba,-1),(
  59.         #(Fenter-local-modes)
  60.         #(es,current-buffer)
  61.     ),(
  62.         #(SELF)
  63.     ))
  64. ))[*]
  65.  
  66.  
  67. Name:F:previous-buffer
  68. Step backward in buffer list.
  69. [*]#(n?,current-buffer,,(
  70.     #(ds,current-buffer,##(ba,-1))
  71. ))
  72. #(g?,##(ba,-1),2,(
  73.     #(..,##(ba,#(--,##(ba,-1),1)))
  74.     #(n?,buffer-number.##(ba,-1),(
  75.         #(Fenter-local-modes)
  76.         #(es,current-buffer)
  77.     ),(
  78.         #(SELF)
  79.     ))
  80. ),(
  81.     #(ba,##(current-buffer))
  82.     #(Fenter-local-modes)
  83.     #(es,current-buffer)
  84.     #(Fmessage,First buffer)
  85. ))
  86. [*]
  87.  
  88.  
  89. Name:F:not-modified
  90. Makes the current buffer think that it hasn't been modified (unless read-only)
  91. [*]#(Fcase,##(lv,mb),
  92.     (1,(#(sv,mb,0))),
  93.     (5,(#(sv,mb,4))),
  94.     (..)
  95. )[*]
  96.  
  97.  
  98. Name:F:select-buffer
  99. Change the current buffer.
  100. [*]#(ds,value,#(Frecall-buffer))
  101. #(Fcompleting-readline,Buffer: ,(
  102.     #(Fswitch-to-buffer,##(value))
  103. ),(
  104.     #(Fmultiple,(Fdelete-n-chars,12),##(ls,(,),buffer-name.##(value)##(2nd-half)),SELF)
  105. ),-)[*]
  106.  
  107.  
  108. Name:F:switch-to-buffer-other-window
  109. [*]#(Fuse-other-window)
  110. #(F:select-buffer)[*]
  111.  
  112.  
  113. Name:Fbuffer-fn
  114. Return the current buffer filename or [No File].
  115. [*]#(Fbuffer-has-fn,(
  116.     #(buffer-filename.##(ba,-1))
  117. ),(
  118.     [No File]
  119. ))[*]
  120.  
  121.  
  122. Name:Fbuffer-has-fn
  123. Return arg1 if the buffer has a filename else arg2.
  124. [*]#(n?,buffer-filename.##(ba,-1),(arg1),(arg2))[*]
  125.  
  126.  
  127. Name:Fbuffer-modified
  128. #(Fbuffer-modified,YES,NO,WRITE) executes
  129. YES if the buffer has been modified, NO if the buffer has not been modified,
  130. and WRITE if the buffer is write-only.
  131. [*]#(Fcase,#(&&,##(lv,mb),3),
  132.     (0,(arg2)),
  133.     (1,(arg1)),
  134.     (2,(arg3)),
  135.     (3,(arg3)),
  136.     (uh-oh))
  137. [*]
  138.  
  139.  
  140. Name:Fbuffer-set-fn
  141. If a name is given, set the buffer's filename to it, else get rid of any
  142. pre-existing filename.
  143. [*]#(==,arg1,,(
  144.     #(n?,buffer-number.##(ba,-1),(
  145.         #(mp,last-buffer,,@##(buffer-number.##(ba,-1))(,))
  146.         #(es,
  147.             buffer-filename.##(ba,-1),
  148.             buffer-name.##(buffer-number.##(ba,-1)),
  149.             buffer-number.##(ba,-1)
  150.         )
  151.     ),(
  152.         #(Ferror,buffer ##(ba,-1) has no namearg3)
  153.     ))
  154. ),(
  155.     #(n?,buffer-number.##(ba,-1),(
  156.         #(SELF,,,-- but it used to)
  157.     ))
  158.     #(ds,temp,#(Fonly-fn,arg1))
  159.     #(==,##(temp),,(
  160.         #(ds,temp,\)
  161.     ))
  162.     #(==,arg2,,,(
  163.         #(ds,temp,##(temp)<arg2>)
  164.     ))
  165.     #(n?,buffer-name.##(temp),(
  166.         #(SELF,arg1,#(==,arg2,,2,(##(++,arg2,1))))
  167.     ),(
  168.         #(ds,buffer-number.##(ba,-1),##(temp))
  169.         #(ds,buffer-name.##(temp),##(ba,-1))
  170.         #(ds,temp,arg1)
  171.         #(==,##(go,temp),*,(
  172.             #(es,buffer-filename.##(ba,-1))
  173.         ),(
  174.             #(ds,buffer-filename.##(ba,-1),#(Fabsolute-filename,arg1))
  175.         ))
  176.     ))
  177. ))[*]
  178.  
  179.  
  180. Name:Fexcurse-buffer
  181. Execute the code in arg1 and switch back to the buffer we were in.  Presumably,
  182. that code changed to a different buffer.
  183. [*]#(ds,old-buffer,##(ba,-1))        ;;remember where we were in case arg1 needs it.
  184. #(..,##(ba,##(ba,-1)#(ds,temp,arg1)))    ;;return to our buffer after running arg1.
  185. ##(temp)                ;;return the results of running arg1.
  186. #(Fenter-local-modes)            ;;make sure the buffer is set up right.
  187. [*]
  188.  
  189.  
  190. Name:Ffind-buffer
  191. Find a buffer with a given filename or file type.  If one is null, then
  192. anything will match it.  The third arg is returned with the current buffer
  193. set to the desired buffer.  If the buffer is not found, the fourth arg is
  194. returned with the old buffer restored.
  195. ##(old-buffer) is set to the old buffer number.
  196. [*]#(ds,old-buffer,##(ba,-1))
  197. #(n?,buffer-name.arg1,(
  198.     #(..,##(ba,##(buffer-name.arg1)))
  199.     #(Fenter-local-modes)
  200.     arg3
  201. ),(
  202.     #(SELF-do,2,arg1,#(Fabsolute-filename,arg2),(arg3),(arg4))
  203. ))
  204. [*]
  205.  
  206.  
  207. Name:Ffind-buffer-do
  208. Look at a single buffer and match it according to #(Ffind-buffer)
  209. [*]#(==,##(ba,arg1),0,(
  210.     #(..,#(ba,##(old-buffer)))
  211.     #(Fenter-local-modes)
  212.     arg5
  213. ),(
  214.     #(==,#(SELF-do,arg2,arg3),yes,(
  215.         #(..,##(ba,arg1))
  216.         #(Fenter-local-modes)
  217.         arg4
  218.     ),(
  219.         #(SELF,#(++,arg1,1),arg2,arg3,(arg4),(arg5))
  220.     ))
  221. ))
  222. [*]
  223.  
  224.  
  225. Name:Ffind-buffer-do-do
  226. Return yes or no if the current buffer has type arg1 and filename arg2.
  227. [*]#(==,arg1,,(
  228.     #(==,arg2,,yes,(
  229.         #(==,#(Fbuffer-fn),arg2,yes,no)
  230.     ))
  231. ),(
  232.     #(==,#(buffer-number.##(ba,-1)),arg1,(
  233.         #(==,arg2,,yes,(
  234.             #(==,#(Fbuffer-fn),arg2,yes,no)
  235.         ))
  236.     ),no)
  237. ))
  238. [*]
  239.  
  240.  
  241. Name:Ffind-or-make-buffer
  242. Given a filename, find a buffer for it or make it.  If arg2 is empty,
  243. scratch the buffer.
  244. [*]#(n?,buffer-name.arg1,(
  245.     #(Fremember-buffer,arg3)
  246.     #(..,##(ba,##(buffer-name.arg1)))
  247.     #(Fenter-local-modes)
  248.     #(==,arg2,,(
  249.         #(sp,[)
  250.         #(dm,])
  251.     ))
  252. ),(
  253.     #(Ffind-unused-buffer,arg1)
  254. ))[*]
  255.  
  256.  
  257. Name:Ffind-unused-buffer
  258. [*]#(..,#(ba,#(ls,(,),buffer-free.)))
  259. #(n?,buffer-free.##(ba,-1),(
  260.     #(es,buffer-free.##(ba,-1))
  261. ),(
  262.     #(ds,buffer-marks.##(ba,-1),PQRSTUVWXYZ)
  263.     #(pm,-26)
  264. ))
  265. #(Fbuffer-set-fn,arg1)
  266. #(Fset-modename,Fun)
  267. #(Fenter-local-modes)
  268. [*]
  269.  
  270.  
  271. Name:Ffind-unused-buffer-do
  272. [*][*]
  273.  
  274.  
  275. Name:Ffor-all-buffers
  276. #(Ffor-all-buffers,STRING) will execute the function named in
  277. STRING for every user buffer.  Equivalent to #(ba,2)STRING #(ba,3)STRING,
  278. etc. for all the buffers that exist.
  279. [*]#(SELF-do,2,(arg1),##(ba,-1))[*]
  280.  
  281.  
  282. Name:Ffor-all-buffers-do
  283. [*]#(==,##(ba,arg1,a),0,(
  284.     #(..,##(ba,arg3))
  285. ),(
  286.     #(arg2,arg1)
  287.     #(SELF,#(++,arg1,1),(arg2),(arg3))
  288. ))
  289. [*]
  290.  
  291.  
  292. Name:Flist-buffers-do
  293. Show information on the buffer given in arg1.
  294.  
  295. [*]#(n?,buffer-number.##(ba,-1),(
  296.         #(Fpad-with,,(
  297.             #(==,arg1,##(old-buffer),., )
  298.             #(Fbuffer-modified,*, , )
  299.             #(Fbuffer-modified, , ,%)
  300.             ( )
  301.             #(buffer-number.arg1)
  302.         ), ,20)
  303.         #(Fpad-with,,(#(lv,nl)), ,8)
  304.         #(Fpad-with,,(#(buffer-mode.arg1)), ,15)
  305.         #(Fbuffer-fn)
  306.         (
  307. )
  308. ))[*]
  309.  
  310.  
  311. Name:Frecall-buffer
  312. Return the most recently visited buffer that isn't visible.
  313. [*]#(ds,-SELF,##(last-buffer))
  314. #(mp,-SELF,,@##(buffer-number.##(ba,-1))(,),@##(buffer-number.##(lv,ow))(,))
  315. #(ds,-SELF,#(Ffirst,#(-SELF)))
  316. #(..,##(go,-SELF))
  317. ##(-SELF)
  318. #(es,-SELF)[*]
  319.  
  320.  
  321. Name:Fremember-buffer
  322. If arg1 is not null, send this buffer to the bottom of the list.  Otherwise,
  323. send it to the top of the list.
  324. [*]#(mp,last-buffer,,@##(buffer-number.##(ba,-1))(,))
  325. #(ds,last-buffer,
  326.     #(==,arg1,,(@##(buffer-number.##(ba,-1))(,)))
  327.     ##(last-buffer)
  328.     #(==,arg1,,,(@##(buffer-number.##(ba,-1))(,)))
  329. )[*]
  330.  
  331.  
  332. Name:Freturn-to-buffer
  333. Send arg1 to remember-buffer.
  334. [*]#(ds,value,#(Ffirst,#(last-buffer)))
  335. #(..,##(go,value))
  336. #(==,##(buffer-name.##(value)),##(ba,-1),(
  337.     #(ds,value,#(Fsecond,#(last-buffer)))
  338.     #(..,##(go,value))
  339. ))
  340. #(Fremember-buffer,arg1)
  341. #(g?,##(buffer-name.##(value)),0,(
  342.     #(==,##(ba,##(buffer-name.##(value))),0,(
  343.         #(an,No such buffer)
  344.     ))
  345. ),(
  346.     #(Fmessage,No such buffer)
  347. ))
  348. #(Fenter-local-modes)
  349. [*]
  350.  
  351.  
  352. Name:Fsave-excursion
  353. [*]#(pm,1)
  354. arg1
  355. #(sp,0)
  356. #(pm)
  357. [*]
  358.  
  359.  
  360. Name:Fswitch-to-buffer
  361. Switch to the buffer named in arg1.  If it exists, execute arg2.  If arg3
  362. is non-null, bury the old buffer.
  363. [*]#(==,arg1,,,(
  364.     #(Fremember-buffer,arg3)
  365.     #(n?,buffer-name.arg1,,(
  366.         #(Ffind-or-make-buffer,arg1)
  367.         #(es,buffer-filename.##(ba,-1))
  368.     ))
  369.     #(==,##(ba,##(buffer-name.arg1)),0,(
  370.         #(Ferror,No buffer "arg1")
  371.     ),(
  372.         #(Fenter-local-modes)
  373.         arg2
  374.     ))
  375. ))[*]